package com.ruoyi.buss.qmcy.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.PreAuthorize;
import com.ruoyi.buss.qmcy.domain.QmcyXykXjfq;
import com.ruoyi.buss.qmcy.service.IQmcyXykXjfqService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 贷记卡现金分期业务Controller
 * 
 * @author sxy
 * @date 2021-07-16
 */
@RestController
@RequestMapping("/xjfq")
public class QmcyXykXjfqController extends BaseController
{
    @Autowired
    private IQmcyXykXjfqService qmcyXykXjfqService;

    /**
     * 查询贷记卡现金分期业务列表
     */
    @PreAuthorize(hasPermi = "buss:xjfq:list")
    @GetMapping("/list")
    public TableDataInfo list(QmcyXykXjfq qmcyXykXjfq)
    {
        startPage();
        List<QmcyXykXjfq> list = qmcyXykXjfqService.selectQmcyXykXjfqList(qmcyXykXjfq);
        return getDataTable(list);
    }

    /**
     * 导出贷记卡现金分期业务列表
     */
    @PreAuthorize(hasPermi = "buss:xjfq:export")
    @Log(title = "贷记卡现金分期业务", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, QmcyXykXjfq qmcyXykXjfq) throws IOException
    {
        List<QmcyXykXjfq> list = qmcyXykXjfqService.selectQmcyXykXjfqList(qmcyXykXjfq);
        ExcelUtil<QmcyXykXjfq> util = new ExcelUtil<QmcyXykXjfq>(QmcyXykXjfq.class);
        util.exportExcel(response, list, "贷记卡现金分期业务数据");
    }

    /**
     * 获取贷记卡现金分期业务详细信息
     */
    @PreAuthorize(hasPermi = "buss:xjfq:query")
    @GetMapping(value = "/{name}")
    public AjaxResult getInfo(@PathVariable("name") String name)
    {
        return AjaxResult.success(qmcyXykXjfqService.selectQmcyXykXjfqById(name));
    }

    /**
     * 新增贷记卡现金分期业务
     */
    @PreAuthorize(hasPermi = "buss:xjfq:add")
    @Log(title = "贷记卡现金分期业务", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody QmcyXykXjfq qmcyXykXjfq)
    {
        return toAjax(qmcyXykXjfqService.insertQmcyXykXjfq(qmcyXykXjfq));
    }

    /**
     * 修改贷记卡现金分期业务
     */
    @PreAuthorize(hasPermi = "buss:xjfq:edit")
    @Log(title = "贷记卡现金分期业务", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody QmcyXykXjfq qmcyXykXjfq)
    {
        return toAjax(qmcyXykXjfqService.updateQmcyXykXjfq(qmcyXykXjfq));
    }

    /**
     * 删除贷记卡现金分期业务
     */
    @PreAuthorize(hasPermi = "buss:xjfq:remove")
    @Log(title = "贷记卡现金分期业务", businessType = BusinessType.DELETE)
	@DeleteMapping("/{names}")
    public AjaxResult remove(@PathVariable String[] names)
    {
        return toAjax(qmcyXykXjfqService.deleteQmcyXykXjfqByIds(names));
    }
}
